#pragma once

#include "config.h"
#include "zuc/motion/zucmotcfg.h"  // ZUC_JOINT_MAX, ZUC_AXIS_MAX
#include "nml_type.hh"
#include "zuc/motion/motion.h"
#include "zuc/nml_intf/motion_types.h"
#include <stdint.h>
#include "zuc/nml_intf/zucpos.h"
#include "zuc/nml_intf/zucpos2.h"
#include "motion/safezone.h"

// Forward class declarations
class ZUC_JOINT_STAT;
class ZUC_AXIS_STAT;
class ZUC_TRAJ_STAT;
class ZUC_MOTION_STAT;
class ZUC_TASK_STAT;
class ZUC_EXTIO_STAT;
class ZUC_SENSOR_STAT;
class ZUC_MONITOR_STAT;
class ZUC_STAT;
class CMS;
class RCS_CMD_CHANNEL;
class RCS_STAT_CHANNEL;
class NML;
class ZUC_ROBOT_SAFETY;
struct ZucPose;
struct PM_CARTESIAN;
struct FuncIOMap;
struct Payload;
struct FtConfig;

// ---------------------
// ZUC TYPE DECLARATIONS
// ---------------------

// NML for base ZUC

#define ZUC_OPERATOR_ERROR_TYPE ((NMLTYPE)11)
#define ZUC_OPERATOR_TEXT_TYPE ((NMLTYPE)12)
#define ZUC_OPERATOR_DISPLAY_TYPE ((NMLTYPE)13)
#define GRPC_RESPONSE_ERROR_TYPE ((NMLTYPE)14)
#define GRPC_RESPONSE_WARNING_TYPE ((NMLTYPE)15)
#define GRPC_RESPONSE_INFO_TYPE ((NMLTYPE)16)

#define ZUC_NULL_TYPE ((NMLTYPE)21)

#define ZUC_SET_DEBUG_TYPE ((NMLTYPE)22)
#define ZUC_EXTIO_SETUP_TYPE ((NMLTYPE)23)
#define ZUC_EXTIO_SETMODE_TYPE ((NMLTYPE)24)
#define ZUC_SET_MAINTENANCE_MODE_TYPE ((NMLTYPE)26)
#define ZUC_SYSTEM_CMD_TYPE ((NMLTYPE)30)

#define ZUC_TORQSENSOR_SETCOMM_TYPE ((NMLTYPE)50)
#define ZUC_TORQSENSOR_SETPAYLOAD_TYPE ((NMLTYPE)51)
#define ZUC_TORQSENSOR_SETMODE_TYPE ((NMLTYPE)52)
#define ZUC_TOOL_SETPAYLOAD_TYPE ((NMLTYPE)53)
#define ZUC_TORQUE_SENSOR_SOFT_LIMIT_TYPE ((NMLTYPE)54)
#define ZUC_TORQUE_SENSOR_FILTER_TYPE ((NMLTYPE)55)
#define ZUC_TORQSENSOR_SETBRAND_TYPE ((NMLTYPE)56)

#define ZUC_ADMITTANCE_DRAG_DEAD_ZONE_TYPE ((NMLTYPE)57)
#define ZUC_COLLISION_GM_RECORD_ENABLE_TYPE ((NMLTYPE)72)

// NML for ZUC_JOINT

// defs for termination conditions
#define ZUC_TRAJ_TERM_COND_STOP 0
#define ZUC_TRAJ_TERM_COND_EXACT 1
#define ZUC_TRAJ_TERM_COND_BLEND 2

#define ZUC_MONITOR_STAT_TYPE ((NMLTYPE)400)

// NML for ZUC_TASK
#define ZUC_APP_SET_CONNECTSTAT_TYPE ((NMLTYPE)600)

// identify dynamics online
#define ZUC_STOP_IDENTIFY_FRICTION_TYPE ((NMLTYPE)613)
#define ZUC_START_IDENTIFY_FRICTION_TYPE ((NMLTYPE)614)
#define ZUC_IDENTIFY_FRICTION_END_POS_TYPE ((NMLTYPE)615)
#define ZUC_IDENTIFY_FRICTION_START_POS_TYPE ((NMLTYPE)616)
#define ZUC_SERVO_DYNAMICS_PARA_TYPE ((NMLTYPE)617)
#define ZUC_SERVO_FRICTION_TYPE ((NMLTYPE)618)
#define ZUC_TASK_START_DYNAMICS_IDENTIFY_TYPE ((NMLTYPE)610)
#define ZUC_TASK_STOP_DYNAMICS_IDENTIFY_TYPE ((NMLTYPE)611)
#define ZUC_IDENTIFY_CYCLE_TIME_TYPE ((NMLTYPE)612)

#define ZUC_COLLISION_SENSITIVITY_TYPE ((NMLTYPE)619)
#define ZUC_BACKDRIVE_ON_TYPE ((NMLTYPE)621)
#define ZUC_FORCE_LIMIT_VALUE_TYPE ((NMLTYPE)622)
#define ZUC_COLLISION_DETECTION_ENABLE_TYPE ((NMLTYPE)623)

#define ZUC_RS485_MESSAGE_TYPE ((NMLTYPE)630)
#define ZUC_TIO_RS485_SIG_PROG_STAT_TYPE ((NMLTYPE)631)

#define ZUC_TORQUE_CONTROL_ENABLE_TYPE ((NMLTYPE)625)
#define ZUC_GRAVITY_DIRECTION_TYPE ((NMLTYPE)626)

#define ZUC_DRAG_CONTROL_ENABLE_TYPE ((NMLTYPE)700)
#define ZUC_DRAG_CONTROL_FC_COMPENSATE_TYPE ((NMLTYPE)701)
#define ZUC_DRAG_CONTROL_FV_COMPENSATE_TYPE ((NMLTYPE)702)
#define ZUC_DRAG_CONTROL_FILTER_FACTOR_TYPE ((NMLTYPE)703)
#define ZUC_DRAG_CONTROL_DITHER_FACTOR_TYPE ((NMLTYPE)704)

// ZUC_AUX type declarations
#define ZUC_AUX_INPUT_WAIT_TYPE ((NMLTYPE)1209)
#define ZUC_AUX_STAT_TYPE ((NMLTYPE)1299)

// ZUC aggregate class type declaration
#define ZUC_LOG_TYPE_IO_CMD 21    // command into ZUC IO controller
#define ZUC_LOG_TYPE_TASK_CMD 51  // command into ZUC Task controller

#define ZUC_INIT_TYPE ((NMLTYPE)1901)
#define ZUC_HALT_TYPE ((NMLTYPE)1902)
#define ZUC_ABORT_TYPE ((NMLTYPE)1903)

#define ZUC_STAT_TYPE ((NMLTYPE)1999)

// ROBOT NML CMD

// clang-format off
#define ZUC_ROB_MOVING_CMD(_ID)         ((NMLTYPE)(100 + (_ID)))
#define ZUC_JOG_CONT_TYPE               ZUC_ROB_MOVING_CMD(1)
#define ZUC_JOG_INCR_TYPE               ZUC_ROB_MOVING_CMD(2)
#define ZUC_JOG_ABS_TYPE                ZUC_ROB_MOVING_CMD(3)
#define ZUC_JOG_MOVJ_TYPE               ZUC_ROB_MOVING_CMD(4)
#define ZUC_JOG_MOVL_TYPE               ZUC_ROB_MOVING_CMD(5)
#define ZUC_JOG_MOVC_TYPE               ZUC_ROB_MOVING_CMD(6)
#define ZUC_JOG_STOP_TYPE               ZUC_ROB_MOVING_CMD(7)
#define ZUC_TRAJ_JOINT_MOVE_TYPE        ZUC_ROB_MOVING_CMD(8)
#define ZUC_TRAJ_LINEAR_MOVE_TYPE       ZUC_ROB_MOVING_CMD(9)
#define ZUC_TRAJ_CIRCULAR_MOVE_TYPE     ZUC_ROB_MOVING_CMD(10)
#define ZUC_TRAJ_MOVC_TYPE              ZUC_ROB_MOVING_CMD(11)
#define ZUC_TRAJ_MOVS_TYPE              ZUC_ROB_MOVING_CMD(12)
#define ZUC_JOG_MULTI_JOINT_TYPE        ZUC_ROB_MOVING_CMD(13)
#define ZUC_SET_DRAG_ENABLE_TYPE        ZUC_ROB_MOVING_CMD(14)
#define ZUC_SET_ROBOT_PAYLOAD_TYPE      ZUC_ROB_MOVING_CMD(15)
#define ZUC_SERVO_HOME_TYPE             ZUC_ROB_MOVING_CMD(16)
#define ZUC_CLEAR_ERROR_TYPE            ZUC_ROB_MOVING_CMD(17)
#define ZUC_SET_BASE_OFFSET_TYPE        ZUC_ROB_MOVING_CMD(18)


#define ZUC_SET_ROBOT_NAME_TYPE ((NMLTYPE)154)
#define ZUC_SETUP_MODBUS_SLAVE_TYPE ((NMLTYPE)155)
#define ZUC_SET_CABINET_ID_TYPE ((NMLTYPE)157)

#define ZUC_ROB_SYNC_CMD(_ID)           ((NMLTYPE)(200 + (_ID)))
#define ZUC_CONVEYOR_ENABLE_TYPE        ZUC_ROB_SYNC_CMD(1)
#define ZUC_CONVEYOR_DISABLE_TYPE       ZUC_ROB_SYNC_CMD(2)
#define ZUC_TRAJ_SET_MODE_TYPE ((NMLTYPE)204)
#define ZUC_TRAJ_SET_ACCELERATION_TYPE ((NMLTYPE)206)
#define ZUC_TRAJ_SET_MAX_VELOCITY_TYPE ((NMLTYPE)207)
#define ZUC_TRAJ_SET_MAX_ACCELERATION_TYPE ((NMLTYPE)208)
#define ZUC_TRAJ_SET_SCALE_TYPE ((NMLTYPE)209)
#define ZUC_TRAJ_SET_RAPID_SCALE_TYPE ((NMLTYPE)210)
#define ZUC_TRAJ_INIT_TYPE ((NMLTYPE)211)
#define ZUC_TRAJ_HALT_TYPE ((NMLTYPE)212)
#define ZUC_TRAJ_ENABLE_TYPE ((NMLTYPE)213)
#define ZUC_TRAJ_DISABLE_TYPE ((NMLTYPE)214)
#define ZUC_TRAJ_ABORT_TYPE ((NMLTYPE)215)
#define ZUC_TRAJ_PAUSE_TYPE ((NMLTYPE)216)
#define ZUC_TRAJ_STEP_TYPE ((NMLTYPE)217)
#define ZUC_TRAJ_RESUME_TYPE ((NMLTYPE)218)
#define ZUC_TRAJ_DELAY_TYPE ((NMLTYPE)219)
#define ZUC_TRAJ_SET_HOME_TYPE ((NMLTYPE)225)
#define ZUC_TRAJ_SET_TELEOP_ENABLE_TYPE ((NMLTYPE)230)
#define ZUC_TRAJ_SET_FO_ENABLE_TYPE ((NMLTYPE)234)
#define ZUC_TRAJ_SET_FH_ENABLE_TYPE ((NMLTYPE)236)
#define ZUC_TRAJ_RIGID_TAP_TYPE ((NMLTYPE)237)
#define ZUC_SET_CHECK_CAN_CONNECTION_TYPE ((NMLTYPE)244)
#define ZUC_RETURN_TO_INITIAL_POSITION_TYPE ((NMLTYPE)252)
#define ZUC_SET_SAFE_ZONE_TYPE ((NMLTYPE)257)
#define ZUC_ROBOT_SAFETY_TYPE ((NMLTYPE)258)
#define ZUC_JOINT_SAFETY_TYPE ((NMLTYPE)259)
#define ZUC_STEP_STATUS_TYPE ((NMLTYPE)260)
#define ZUC_SET_COLLISION_OPTION_TYPE ((NMLTYPE)261)
#define ZUC_SET_GRPC_ERRCODE_TYPE ((NMLTYPE)262)
#define ZUC_TOPPRA_FINISH_LEFT_TC_TYPE ((NMLTYPE)263)
#define ZUC_TOPPRA_FIRST_COMMAND_TYPE ((NMLTYPE)264)
#define ZUC_SET_ROBOT_SAFETY_CUSTOMIZE_TYPE ((NMLTYPE)265)
#define ZUC_REDUCE_SAFETY_TYPE ((NMLTYPE)266)
#define Robot_7_DOF_INV_INFORM_TYPE ((NMLTYPE)267)
#define ZUC_DRAG_SPEED_LIMIT_TYPE ((NMLTYPE)268)
#define ZUC_COLLECT_DIAG_DATA_TYPE ((NMLTYPE)277)
#define Robot_SET_FULL_DH_FLAG_TYPE ((NMLTYPE)278)
#define Robot_SET_7_DOF_KINE_PARAM_ALPHA_K_TYPE ((NMLTYPE)279)
#define ZUC_IO_STAT_TYPE ((NMLTYPE)280)
#define ZUC_SAFE_STAT_TYPE ((NMLTYPE)281)
#define ZUC_TIO_STAT_TYPE ((NMLTYPE)282)
#define ZUC_TRAJ_SET_END_FORCE_CONDITION_TYPE ((NMLTYPE)289)
#define ZUC_TRAJ_SET_ADMITOP_ENABLE_TYPE ((NMLTYPE)290)
#define ZUC_TRAJ_SET_ADMITTANCE_ENABLE_TYPE ((NMLTYPE)291)
#define ZUC_TRAJ_SET_ADMITTANCE_OPTION_TYPE ((NMLTYPE)292)
#define ZUC_TRAJ_SET_ADMITTANCE_CONFIG_TYPE ((NMLTYPE)293)
#define ZUC_TRAJ_SET_SERVOJOP_ENABLE_TYPE ((NMLTYPE)295)
#define ZUC_TRAJ_SET_COMPLIANCE_ENABLE_TYPE ((NMLTYPE)297)
#define ZUC_TRAJ_SET_ADMITTANCE_FRAME_TYPE ((NMLTYPE)298)
#define ZUC_TRAJ_DISABLE_FORCE_CONTROL_TYPE ((NMLTYPE)299)

#define ZUC_TRAJ_STAT_TYPE ((NMLTYPE)300)
#define ZUC_MOTION_INIT_TYPE ((NMLTYPE)321)
#define ZUC_MOTION_HALT_TYPE ((NMLTYPE)322)
#define ZUC_MOTION_ABORT_TYPE ((NMLTYPE)323)
#define ZUC_MOTION_SET_AOUT_TYPE ((NMLTYPE)324)
#define ZUC_MOTION_SET_DOUT_TYPE ((NMLTYPE)325)
#define ZUC_MOTION_ADAPTIVE_TYPE ((NMLTYPE)326)
#define ZUC_MOTION_EXIT_PROTECT_TYPE ((NMLTYPE)327)
#define ZUC_MOTION_KINE_INVERSE_TYPE ((NMLTYPE)328)
#define ZUC_MOTION_KINE_FORWARD_TYPE ((NMLTYPE)329)
#define ZUC_MOTION_SET_FUNCDI_TYPE ((NMLTYPE)330)
#define ZUC_MOTION_SET_FUNCDO_TYPE ((NMLTYPE)331)
#define ZUC_MOTION_PERCENTAGE_MODE_TYPE ((NMLTYPE)312)
#define ZUC_MOTION_PERCENTAGE_MODE_LEVEL_VALUE_TYPE ((NMLTYPE)313)
#define ZUC_MOTION_SETUP_IO_CHANNEL_TYPE ((NMLTYPE)315)
#define ZUC_MOTION_SET_BR_STRT_VOLTAGE_TYPE ((NMLTYPE)316)
#define ZUC_SHUT_DOWN_TYPE ((NMLTYPE)317)
#define ZUC_FUNCTION_SAFTY_PARA_TYPE ((NMLTYPE)318)
#define ZUC_MOTION_SET_SAFETY_FUNCDI_TYPE ((NMLTYPE)319)
#define ZUC_MOTION_SET_SAFETY_FUNCDO_TYPE ((NMLTYPE)320)
#define ZUC_MOTION_SET_CAPTURE_TYPE ((NMLTYPE)332)
#define ZUC_MOTION_CLEAR_CAPTURE_TYPE ((NMLTYPE)333)
#define ZUC_MOTION_ONE_KEY_OP_TYPE ((NMLTYPE)334)
#define ZUC_MOTION_SET_MOVE_VEL_TYPE ((NMLTYPE)335)
#define ZUC_MBTIO_ADD_SIGNAL_TYPE ((NMLTYPE)340)
#define ZUC_MBTIO_DEL_SIGNAL_TYPE ((NMLTYPE)341)
#define ZUC_MBTIO_UPDATE_SIGNAL_TYPE ((NMLTYPE)342)
#define ZUC_MBTIO_SEND_COMMAND_TYPE ((NMLTYPE)343)
#define ZUC_MOTION_SET_FREE_BUTTON_OPT_TYPE ((NMLTYPE)345)
#define ZUC_MOTION_SET_FREE_PROG_BUTTON_OPT_TYPE ((NMLTYPE)346)
#define ZUC_MOTION_SET_POINT_BUTTON_OPT_TYPE ((NMLTYPE)347)
#define ZUC_MOTION_REDUCE_MODE_TYPE ((NMLTYPE)348)
#define ZUC_MOTION_SET_HOME_VEL_TYPE ((NMLTYPE)349)
#define ZUC_SET_SERVO_PARAM_TYPE ((NMLTYPE)350)
#define ZUC_SERVO_UPGRADE_TYPE ((NMLTYPE)381)
#define ZUC_EXTIO_STAT_TYPE ((NMLTYPE)390)
#define ZUC_SENSOR_STAT_TYPE ((NMLTYPE)391)
#define ZUC_MOTION_STAT_TYPE ((NMLTYPE)399)

#define ZUC_ROB_CONFIG_CMD(_ID)                 ((NMLTYPE)(400 + (_ID)))
#define ZUC_SET_CUSTOM_POSE_TYPE                ZUC_ROB_CONFIG_CMD(1)
#define ZUC_SET_SERVOJ_PARAMETER_TYPE           ZUC_ROB_CONFIG_CMD(2)
#define ZUC_TRAJ_SET_TELEOP_TOOL_ENABLE_TYPE    ZUC_ROB_CONFIG_CMD(3)
#define ZUC_SET_TOOL_ID_TYPE                    ZUC_ROB_CONFIG_CMD(4)
#define ZUC_SET_USER_ID_TYPE                    ZUC_ROB_CONFIG_CMD(5)
#define ZUC_SET_BASE_ID_TYPE                    ZUC_ROB_CONFIG_CMD(6)

#define ZUC_MOTION_CONFIG_CMD(_ID)              ((NMLTYPE)(500 + (_ID)))
#define ZUC_TRAJ_SET_ROBOT_TOOL_OFFSET_TYPE     ZUC_MOTION_CONFIG_CMD(1)
#define ZUC_TRAJ_SET_ROBOT_USER_FRAME_TYPE      ZUC_MOTION_CONFIG_CMD(2)
#define ZUC_TRAJ_SET_PAYLOAD_TYPE               ZUC_MOTION_CONFIG_CMD(3)
#define ZUC_TRAJ_CALIB_DHPARAM_TYPE             ZUC_MOTION_CONFIG_CMD(4)
#define ZUC_SET_MUTI_TOOL_OFFSET_TYPE           ZUC_MOTION_CONFIG_CMD(5)
#define ZUC_SET_MUTI_USER_OFFSET_TYPE           ZUC_MOTION_CONFIG_CMD(6)

// TASK NML CMD
#define ZUC_TASK_CMD(_ID)                       ((NMLTYPE)(2000 + (_ID)))
#define ZUC_TASK_INIT_TYPE                      ZUC_TASK_CMD(1)
#define ZUC_TASK_HALT_TYPE                      ZUC_TASK_CMD(2)
#define ZUC_TASK_ABORT_TYPE                     ZUC_TASK_CMD(3)
#define ZUC_TASK_SET_MODE_TYPE                  ZUC_TASK_CMD(4)
#define ZUC_TASK_SET_STATE_TYPE                 ZUC_TASK_CMD(5)
#define ZUC_TASK_PLAN_OPEN_TYPE                 ZUC_TASK_CMD(6)
#define ZUC_TASK_PLAN_RUN_TYPE                  ZUC_TASK_CMD(7)
#define ZUC_TASK_PLAN_READ_TYPE                 ZUC_TASK_CMD(8)
#define ZUC_TASK_PLAN_EXECUTE_TYPE              ZUC_TASK_CMD(9)
#define ZUC_TASK_PLAN_PAUSE_TYPE                ZUC_TASK_CMD(10)
#define ZUC_TASK_PLAN_STEP_TYPE                 ZUC_TASK_CMD(11)
#define ZUC_TASK_PLAN_RESUME_TYPE               ZUC_TASK_CMD(12)
#define ZUC_TASK_PLAN_END_TYPE                  ZUC_TASK_CMD(13)
#define ZUC_TASK_PLAN_CLOSE_TYPE                ZUC_TASK_CMD(14)
#define ZUC_TASK_PLAN_INIT_TYPE                 ZUC_TASK_CMD(15)
#define ZUC_TASK_PLAN_SYNCH_TYPE                ZUC_TASK_CMD(16)
#define ZUC_TASK_PLAN_SET_OPTIONAL_STOP_TYPE    ZUC_TASK_CMD(17)
#define ZUC_TASK_PLAN_SET_BLOCK_DELETE_TYPE     ZUC_TASK_CMD(18)
#define ZUC_TASK_PLAN_OPTIONAL_STOP_TYPE        ZUC_TASK_CMD(19)
#define ZUC_TASK_CALC_TCP_TYPE                  ZUC_TASK_CMD(20)
#define ZUC_TASK_USER_DEFINED_VARIABLE_TYPE     ZUC_TASK_CMD(21)
#define ZUC_TASK_SET_AUTOWORK_TYPE              ZUC_TASK_CMD(22)
#define ZUC_TASK_CALC_USER_TYPE                 ZUC_TASK_CMD(23)
#define ZUC_TASK_START_PAYLOAD_IDENTIFY_TRAJ_TYPE           ZUC_TASK_CMD(24)
#define ZUC_TASK_SET_PAYLOAD_IDENTIFY_TRAJ_STARTPOS_TYPE    ZUC_TASK_CMD(25)
#define ZUC_GET_PAYLOAD_IDENTIFY_RESULT_TYPE                ZUC_TASK_CMD(26)
#define ZUC_TASK_RESET_PAYLOAD_IDENTIFY_STATUS_TYPE         ZUC_TASK_CMD(27)
#define ZUC_TASK_SET_SCRIPT_BACKUP_TYPE                     ZUC_TASK_CMD(28)
#define ZUC_TASK_SETUP_TIO_RS485_MODE_TYPE                  ZUC_TASK_CMD(29)
#define ZUC_TASK_SETUP_TIO_RS485_COMM_TYPE                  ZUC_TASK_CMD(30)
#define ZUC_TASK_SETUP_TIO_PIN_MODE_TYPE                    ZUC_TASK_CMD(31)
#define ZUC_TASK_SETUP_TIO_VOUT_ENA_TYPE                    ZUC_TASK_CMD(32)
#define ZUC_TASK_SETUP_TIO_VOUT_VOL_TYPE                    ZUC_TASK_CMD(33)
#define ZUC_SET_NET_EXCEPTION_HANDLE_TYPE                   ZUC_TASK_CMD(34)
#define ZUC_TASK_SET_PAYLOAD_IDENTIFY_TRAJ_ENDPOS_TYPE      ZUC_TASK_CMD(35)
#define ZUC_SET_CABVOLTAGE_TYPE                             ZUC_TASK_CMD(36)
#define ZUC_SET_SAFE_ATTITUDE_TYPE                          ZUC_TASK_CMD(37)
#define ZUC_TASK_CALC_SAFEATT_TYPE                          ZUC_TASK_CMD(38)
#define ZUC_SET_SIM_ENABLE_TYPE                             ZUC_TASK_CMD(39)
#define ZUC_SET_SIM_ROBOT_TYPE                              ZUC_TASK_CMD(40)
#define ZUC_SYNC_ZUCSETTINGS_TYPE                           ZUC_TASK_CMD(41)
#define ZUC_TASK_SET_OPERATION_MODE_TYPE                    ZUC_TASK_CMD(42)
#define ZUC_SET_PLANNER_JERK_TYPE                           ZUC_TASK_CMD(43)
#define ZUC_TASK_STAT_TYPE                                  ZUC_TASK_CMD(44)

// AXIS NML CMD
#define ZUC_AXIS_CMD(_ID)                       ((NMLTYPE)(3000 + (_ID)))
#define ZUC_AXIS_CMD_POWER_TYPE                 ZUC_AXIS_CMD(1)
#define ZUC_AXIS_CMD_RESET_TYPE                 ZUC_AXIS_CMD(2)
#define ZUC_JOINT_SET_MIN_POSITION_LIMIT_TYPE   ZUC_AXIS_CMD(3)
#define ZUC_JOINT_SET_MAX_POSITION_LIMIT_TYPE   ZUC_AXIS_CMD(4)

// IO NML CMD
#define ZUC_IO_CMD(_ID)           ((NMLTYPE)(3500 + (_ID)))

// clang-format on

// define network exeception robot motion type
#define MOT_KEEP 0
#define MOT_PAUSE 1
#define MOT_ABORT 2

// types for ZUC_TASK mode
enum ZUC_TASK_MODE_ENUM
{
    ZUC_TASK_MODE_MANUAL = 1,
    ZUC_TASK_MODE_AUTO = 2,
    ZUC_TASK_MODE_MDI = 3,
    ZUC_TASK_MODE_DRAG = 4,
    ZUC_TASK_MODE_EXTERNAL = 5
};

// types for switch manual and auto mode
enum ZUC_TASK_OPERATION_MODE_ENUM
{
    ZUC_TASK_OPERATION_MODE_MANUAL = 0,
    ZUC_TASK_OPERATION_MODE_AUTO = 1,
};

// types for ZUC_TASK state
enum ZUC_TASK_STATE_ENUM
{
    ZUC_TASK_STATE_POWERED_OFF = 1,
    ZUC_TASK_STATE_POWERED_ON = 2,
    ZUC_TASK_STATE_OFF = 3,
    ZUC_TASK_STATE_ON = 4
};

// types for ZUC_TASK execState
enum ZUC_TASK_EXEC_ENUM
{
    ZUC_TASK_EXEC_ERROR = 1,
    ZUC_TASK_EXEC_DONE = 2,
    ZUC_TASK_EXEC_WAITING_FOR_MOTION = 3,
    ZUC_TASK_EXEC_WAITING_FOR_MOTION_QUEUE = 4,
    ZUC_TASK_EXEC_WAITING_FOR_IO = 5,
    ZUC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO = 7,
    ZUC_TASK_EXEC_WAITING_FOR_DELAY = 8,
    ZUC_TASK_EXEC_WAITING_FOR_SYSTEM_CMD = 9,
    ZUC_TASK_EXEC_WAITING_FOR_SPINDLE_ORIENTED = 10
};

// types for ZUC_TASK interpState
enum ZUC_TASK_INTERP_ENUM
{
    ZUC_TASK_INTERP_IDLE = 0,
    ZUC_TASK_INTERP_READING = 1,
    ZUC_TASK_INTERP_PAUSED = 2,
    ZUC_TASK_INTERP_WAITING = 3
};

// types for motion control
enum ZUC_TRAJ_MODE_ENUM
{
    ZUC_TRAJ_MODE_FREE = 1,    // independent-axis motion,
    ZUC_TRAJ_MODE_COORD = 2,   // coordinated-axis motion,
    ZUC_TRAJ_MODE_TELEOP = 3,  // velocity based world coordinates motion,
    ZUC_TRAJ_MODE_TELEOP_TOOL = 4,
    ZUC_TRAJ_MODE_DRAG = 5,
    ZUC_TRAJ_MODE_SERVOJOP = 6,
    ZUC_TRAJ_MODE_ADMITTANCE = 7
};

// types for zucIoAbort() reasons
enum ZUC_IO_ABORT_REASON_ENUM
{
    ZUC_ABORT_TASK_EXEC_ERROR = 1,
    ZUC_ABORT_AUX_ESTOP = 2,
    ZUC_ABORT_MOTION_OR_IO_RCS_ERROR = 3,
    ZUC_ABORT_TASK_STATE_OFF = 4,
    ZUC_ABORT_TASK_STATE_POWERD_ON = 5,
    ZUC_ABORT_TASK_STATE_POWERED_OFF = 6,
    ZUC_ABORT_TASK_STATE_NOT_ON = 7,
    ZUC_ABORT_TASK_ABORT = 8,
    ZUC_ABORT_INTERPRETER_ERROR = 9,       // interpreter failed during readahead
    ZUC_ABORT_INTERPRETER_ERROR_MDI = 10,  // interpreter failed during MDI execution
    ZUC_ABORT_THREAD_NUM_OVER_LIMIT = 11,
    ZUC_ABORT_USER = 100  // user-defined abort codes start here
};
// --------------
// ZUC VOCABULARY
// --------------

// NML formatting function
extern int zucFormat(NMLTYPE type, void* buffer, CMS* cms);

// decls for command line args-- mains are responsible for setting these
// so that other modules can get cmd line args for ad hoc processing
extern int Argc;
extern char** Argv;

// ------------------------
// IMPLEMENTATION FUNCTIONS
// ------------------------

// implementation functions for ZUC error, message types
// intended to be implemented in main() file, by writing to NML buffer

// print an error
extern int zucOperatorError(int id, const char* fmt, ...) __attribute__((format(printf, 2, 3)));

extern int zucOperatorWarning(int id, const char* fmt, ...) __attribute__((format(printf, 2, 3)));

// print general text
extern int zucOperatorText(int id, const char* fmt, ...) __attribute__((format(printf, 2, 3)));

// print note to operator
extern int zucOperatorDisplay(int id, const char* fmt, ...) __attribute__((format(printf, 2, 3)));

enum ZucJointSafetyType
{
    JOINT_VEL_LIMIT = 1,
    JOINT_ERR_LIMIT = 2,
};

enum ZucRobotSafetyType
{
    ROBOT_ALL_PARA = 0,
    ROBOT_MOMENTUM_PARA = 1,
    ROBOT_TCPVEL_PARA = 2,
    ROBOT_POWER_PARA = 3,
    ROBOT_STOPPINGDIST_PARA = 4,
    ROBOT_STOPPINGTIME_PARA = 5,
};

enum ZucRobotReducedSafetyType
{
    ROBOT_ALL_REDUCED_REDUCED_PARA = 0,
    ROBOT_REDUCED_TCPVEL_PARA = 1,
    REBOT_REDUCED_ELBOWVEL_PARA = 2,
    ROBOT_REDUCED_MOMENTUM_PARA = 3,
    ROBOT_REDUCED_POWER_PARA = 4,
    ROBOT_REDUCED_STOPPINGDIST_PARA = 5,
    ROBOT_REDUCED_STOPPINGTIME_PARA = 6,
};

enum ZucRobotSafetyCustom
{
    USER_DEFINED = 0,
    NOLIMITSAFETYSETTING = 1,
    LOOSESAFETYSETTING = 2,
    MEDIUMSAFETYSETTING = 3,
    STRICTSAFETYSETTING = 4,
};

extern ZUC_STAT* zucStatus;
extern ZUC_MOTION_STAT* zucMotionStatus;
enum ZucJointType
{
    ZUC_LINEAR = 1,
    ZUC_ANGULAR = 2,
};

typedef double ZucLinearUnits;
typedef double ZucAngularUnits;

struct position
{
    float x;
    float y;
    float z;
    float r;
    float p;
    float u;
};
